package com.sdk;

import com.quickgame.android.sdk.bean.QGOrderInfo;
import com.quickgame.android.sdk.bean.QGRoleInfo;
import com.rxgscd.yy.MainActivity;

import android.util.Log;


public class API {

	//初始化
	public static  void Init()
    {
		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.INIT) ;
    }
	//初始化
	public static  void Init(String wx_APP_ID,String wx_AppSecret,String wx_Partnerid,String wx_SIGNKEY)
    {
		MainActivity.APP_ID = wx_APP_ID;// 微信APPID
		MainActivity.AppSecret = wx_AppSecret;// 微信密钥
		MainActivity.Partnerid = wx_Partnerid;// 微信商户号
		MainActivity.SIGNKEY = wx_SIGNKEY;// 微信签名密钥
		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.INIT) ;
    }
    final static String TAG = "API";
    static UnityCallback _unityCallback;

    public static void SetCallback(UnityCallback unityCallback) {
        _unityCallback = unityCallback;
    }

    public static void S_SendMessage(int msgType, String msgTypeName, String msg1, String msg2, String msg3) {
        if (_unityCallback != null) {
            _unityCallback.SendMessage(msgType, msgTypeName, msg1, msg2, msg3);
        } else {
            Log.e(TAG, "_unityCallback==null.........." + msgType + ".........." + msgTypeName);
        }
    }
	public static  void GetVersion()
    {
		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.GETAPKVERSION) ;
    }
	
	public static	String UpdateUrl;
	//更新
	public static void UpdateGame(String updateUrl) 
	{
		UpdateUrl = updateUrl;
		Log.i("UNITY", "API UpdateGame UpdateUrl == " + UpdateUrl);
		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.UPDATEGAME) ;
	}  
    
	//设置LOG开关
    public static void SetOpenLog()
    {
    	MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.SETOPENLOG) ;
    }
    
    //获取平台
    public static void GetPlatform()
    {
    	MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.GETPLATFORM) ;
    }
    
    //登录
    public static void Login()
    {
    	Log.i("UNITY", "start com.sdk login function");
    	MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.LOGIN) ;
    }
   
    //注销
   public static void LogOut()
   {
   		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.LOGOUT) ;
   }
   
	 public static	String PrepayId;
	 public static	String NonceStr;
	 public static 	String Sign; 
   public static void Pay(String prepayId, String nonceStr, String sign)
   {
	   PrepayId = prepayId;
	   NonceStr = nonceStr;
	   Sign = sign;
	   Log.i("UNITY", "开始JAVA支付    PrepayId == " + PrepayId + "   NonceStr == " + NonceStr + "    Sign ==" + Sign);
	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.PAY) ;
   }
   
   public static String OrderInfo;
   public static void ZhiFuBaoPay(String orderInfo) {
	   OrderInfo = orderInfo;
	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.ZHIFUBAOPAY);
   }
   
   public static String PlayerId; 
   public static String Provider; 
   public static void OnProfileSignIn(String provider, String userId)
   {
	    Provider = provider;
	    PlayerId=userId;
	    Log.i("UNITY", "call com.sdk OnProfileSignIn function : Provider ==" + Provider + "   PlayerId == " + PlayerId);
   		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.ONPROFILESIGNIN) ;
   }
   
   public static void OnProfileSignOff()
   {
   		MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.ONPROFILESIGNOFF) ;
   		Log.i("UNITY", "start com.sdk OnProfileSignOff function");
   }
   
   public static double MoneyCount; 
   public static double DiamondCount; 
   public static void UmengPay(double money,double diamond) {
//	   MoneyCount = money;
//	   DiamondCount = diamond;
//	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.UMENGPAY) ;
//	   Log.i("UNITY", "call com.sdk UmengPay function : MoneyCount ==" + MoneyCount + "   DiamondCount == " + DiamondCount);
   }
   
   public static String WXText; 
   public static void WXTextSet(String mText)
   {
	   WXText = mText;
   }
   
   public static String m_EventId;
   public static String m_EventData;
   public static void UMEventReport(String eventId, String eventData) 
   {
	   m_EventId = eventId;
	   m_EventData = eventData;
	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.UMReport);
   }
   
   public static QGOrderInfo qgOrderInfo;
   public static QGRoleInfo qgRoleInfo;
   
   public static void SaveQGRoleInfo(String roleId, String roleLevel, String roleName, String serverName, String vipLevel) {
       Log.e("FBLog", "设置角色信息......start com.sdk SaveQGRoleInfo function");
       qgRoleInfo = MainActivity.instance.SetQGRoleInfo(roleId, roleLevel, roleName, serverName, vipLevel);
	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.QGROLE);
   }
   
   public static void SaveQGOrderInfo(String OrderSubject, String orderId, String extra_paras, double amount, String callback, String goodsId) {
       Log.e("FBLog", "fb开始支付.......start com.sdk SaveQGOrderInfo function");
       qgOrderInfo = MainActivity.instance.SetQGOrderInfo(OrderSubject, orderId, extra_paras, amount, callback, goodsId);
	   MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.QGPAY);
   }

   public static String creteRoleId = "";
   public static void  CreteRoleFinish(String roleId) {
       creteRoleId = roleId;
       MainActivity.myHandler.sendEmptyMessage(SDKUtility.SDKFUNTYPE.QGCreateRole);
   }
}
